﻿using AutoMapper;
using Domain.Entity.In;
using Domain.Entity.search;
using Domain.IRepository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.Instock_dService
{
    public class Instock_dService : IInstock_dService
    {
        private readonly IInstock_dRepository instock_DRepository;
        private readonly IMapper mapper;

        public Instock_dService(IInstock_dRepository instock_DRepository,IMapper mapper)
        {
            this.instock_DRepository = instock_DRepository;
            this.mapper = mapper;
        }

        //添加入库明细
        public async Task<int> AddInstock_d(AddInstock_dDto addInstock_DDto)
        {
            Instock_d instock_D = mapper.Map<Instock_d>(addInstock_DDto);
            return await instock_DRepository.AddInstock_d(instock_D);
        }

        //删除入库明细
        public async Task<int> DeleteInstock_d(int indid)
        {
            return await instock_DRepository.DeleteInstock_d(indid);
        }


        //根据入库单id查询明细
        public async Task<List<Instock_d>> GetInstock_Ds(int instockid)
        {
            return await instock_DRepository.GetInstock_Ds(instockid);
        }


        //修改入库明细
        public async Task<int> UpdateInstock_d(AddInstock_dDto addInstock_DDto)
        {
            Instock_d instock_D = mapper.Map<Instock_d>(addInstock_DDto);
            return await instock_DRepository.UpdateInstock_d(instock_D);
        }
    }
}
